using huqiang.Core.HGUI;
using System;
using UnityEngine;
using huqiang.UIComposite;
using huqiang.UIEvent;
using huqiang;
using huqiang.Data;
using huqiang.UIModel;

public class Button:UIPage
{
    //反射UI界面上的物体
    class View
    {
        public UserEvent Ele;
        public UserEvent Image;
        public UserEvent Text;
        public UserEvent Circle;
        public GestureEvent Polygon;
    }
    View view;
    public override void Initial(UIElement parent, object dat = null)
    {
        base.Initial(parent, dat);
        view = LoadUI<View>("baseUI", "Button");//"baseUI"创建的bytes文件名,"page"为创建的页面名
        InitialEvent();
    }
    void InitialEvent()
    {
        view.Ele.Click = (o, e) => { Debug.Log("UI 元素被单击"); };
        view.Image.Click = (o, e) => { Debug.Log("Image 被单击"); };
        view.Text.Click = (o, e) => { Debug.Log("文本被单击"); };
        view.Circle.Click = (o, e) => { Debug.Log("圆形被单击"); };
        view.Circle.Drag = view.Circle.DragEnd= (o, e, v) => { view.Circle.Context.localPosition += (Vector3)v; };

        view.Polygon.Click = (o, e) => { Debug.Log("多边形被单击"); };
        view.Polygon.Drag = view.Polygon.DragEnd = (o, e, v) => { view.Polygon.Context.localPosition += (Vector3)v; };
        view.Polygon.TowFingerMove = (o) =>{ 
            view.Polygon.Context.localScale += new Vector3(o.DeltaScale,o.DeltaScale,0);
            view.Polygon.Context.localRotation *= Quaternion.Euler(0,0, o.DeltaAngle);
        };
    }
}
